home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2003 June / macformat-130.iso / mac / Reviewed⁄Demos / Spearhead Demo / demota / pak1.pk3 / anim / shoot.scr < prev    next >
Encoding:
Text File  |  2002-10-21  |  6.5 KB  |  256 lines

  1. //-------
  2. // Shoot
  3. //-------
  4. // Shoot at someone.
  5.  
  6. //println "Shoot.scr called"
  7. waitexec "anim/default_inithandler.scr"
  8. waitexec anim/smoking.scr::SmokeRemoveCigarette
  9. waitexec anim/reload.scr::ReloadInit
  10. self weaponcommand mainhand attachtohand mainhand
  11.  
  12. // Initialise say manager
  13. self waitthread anim/SayManager.scr::Init
  14.  
  15. start:
  16.  
  17. if (self.enemy)
  18. {
  19.     local.distance = self.distancetoenemy
  20.     if (local.distance < self.reallyshortrange)
  21.     {
  22.         waitexec anim/attack.scr::AttackDoMelee
  23.         end
  24.     }
  25. }
  26.  
  27. // Need a fast crossblend so the shoot is snappy, which means we rely on the aim animation
  28. // lining up perfectly.
  29. self.blendtime = 0.10
  30.  
  31.  
  32. switch (self.position)
  33. {
  34.     dead:
  35.         println "ERROR SHOOT.SCR Error: Dead guy trying to shoot.  This isn't meant to be Undying!"
  36.         break
  37.  
  38.     stand:
  39.     walk:
  40.     run:
  41.         switch (self.weapongroup)
  42.         {
  43.             // If this works, it should be able to handle most weapons:
  44.             mp44:
  45.             bar:
  46.             thompson:
  47.             mp40:
  48.                 self thread anim/SayManager.scr::SayManager face_attack 5
  49.                 self setmotionanim (self.weapongroup + "_stand_alert_legs")
  50.                 self setactionanim (self.weapongroup + "_shootauto") -60 60
  51.                 self waittill upperanimdone
  52.                 waitexec anim/reload.scr::Reload 1 NIL 1
  53.                 break
  54.             rifle:
  55.             pistol:
  56.             bazooka:
  57.                 self thread anim/SayManager.scr::SayManager face_attack 5
  58.                 self setmotionanim (self.weapongroup + "_stand_alert_legs")
  59.                 //self setactionanim (self.weapongroup + "_shoot") -60 60
  60.                 waitexec anim/shoot.scr::PlayShootActionAnim
  61.                 self waittill upperanimdone
  62.                 waitexec anim/reload.scr::Reload 1 NIL 1
  63.                 break
  64.  
  65.             //bazooka:
  66.             //    self thread anim/SayManager.scr::SayManager face_attack 5
  67.             //    self setmotionanim (rifle_stand_alert_legs)
  68.             //    self setactionanim (self.weapongroup + "_shoot") -60 60
  69.             //    self waittill upperanimdone
  70.             //    waitexec anim/reload.scr::Reload 1 NIL 1
  71.             //    break
  72.  
  73.             grenade:
  74.                 //println "Stand/Throw Grenade"
  75.                 self setmotionanim grenade_throw
  76.                 self waittill flaggedanimdone
  77.                 break
  78.  
  79.             unarmed:
  80.                 self setmotionanim unarmed_stand_alert_legs
  81.                 self waittill flaggedanimdone
  82.                 break
  83.  
  84.             default:
  85.                 println ("ERROR SHOOT.SCR Shoot Stand Default case for "+self.weapongroup+" weapon group - fix shoot.scr")
  86.                 //self setmotionanim aim_leg_stance
  87.                 //self setactionanim rifle_shoot    -60 60
  88.                 self setmotionanim unarmed_stand_alert_legs
  89.                 self waittill flaggedanimdone
  90.                 break
  91.         }
  92.         break
  93.  
  94.     crouch:
  95.     crouch_walk:
  96.     crouch_run:
  97.         switch (self.weapongroup)
  98.         {
  99.             // autos - jbw
  100.             bar:
  101.             thompson:
  102.             mp44:
  103.             mp40:
  104.                 self thread anim/SayManager.scr::SayManager face_attack 5
  105.                 self setmotionanim (self.weapongroup + "_crouch_alert")
  106.                 self setactionanim (self.weapongroup + "_shootauto") -60 60
  107.                 self waittill upperanimdone
  108.                 waitexec anim/reload.scr::Reload 1 NIL 1
  109.                 break
  110.             bazooka:
  111.             pistol:
  112.             rifle:
  113.             grenade:
  114.                 self thread anim/SayManager.scr::SayManager face_attack 5
  115.                 switch (self.weapon)
  116.                 {
  117.                     case "springfield '03 sniper":
  118.                     case "mauser kar 98k":
  119.                     case "mauser kar 98d sniper":
  120.                         self setmotionanim (self.weapongroup + "_crouch_alert")
  121.                         self setactionanim kar98_shoot -60 60
  122.                         self waittill upperanimdone
  123.                         waitexec anim/reload.scr::Reload 1 1 1
  124.                         break
  125.                     default:
  126.                         self setmotionanim (self.weapongroup + "_crouch_alert")
  127.                         self setactionanim (self.weapongroup + "_shoot") -60 60
  128.                         self waittill upperanimdone
  129.                         waitexec anim/reload.scr::Reload 1 0 1
  130.                         break
  131.                 }
  132.                 break
  133.  
  134.             default:
  135.                 println ("ERROR SHOOT.SCR Shoot Crouch Default case for "+self.weapongroup+" weapon group - fix shoot.scr")
  136.                 self setmotionanim rifle_crouch_alert
  137.                 self waittill flaggedanimdone
  138.                 break
  139.         }
  140.  
  141.         break
  142.  
  143.     prone:
  144.     prone_walk:
  145.         switch (self.weapongroup)
  146.         {
  147.             pistol:
  148.             rifle:
  149.             mp40:
  150.             mp44:
  151.             bar:
  152.             thompson:
  153.                 //println "Prone/Fire SMG"
  154.                 self thread anim/SayManager.scr::SayManager face_attack 5
  155.                 self setmotionanim (self.weapongroup + "_prone_legs")
  156.                 self setactionanim (self.weapongroup + "_prone_shoot") -60 60
  157.                 self waittill upperanimdone
  158.                 break
  159.  
  160.             bazooka:
  161.                 // Need to crouch first (aim should take care of this)
  162.                 println "ERROR SHOOT.SCR Tried to shoot bazooka while prone.  Going to crouch first"
  163.                 waitexec anim/crouch.scr::transition
  164.                 self thread anim/SayManager.scr::SayManager face_attack 5
  165.                 self setmotionanim (bazooka_crouch_alert)
  166.                 self setactionanim (self.weapongroup + "_aim") -60 60
  167.                 wait self.blendtime
  168.                 self.position = crouch
  169.                 goto start
  170.  
  171.             grenade:
  172.                 //println "Prone/Fire Grenade"
  173.                 //what is grenade_prone_attack_straight ?
  174.                 self setmotionanim grenade_prone_throw_straight // broken legs
  175.                 self waittill flaggedanimdone
  176.                 break
  177.  
  178.             default:
  179.                 println ("ERROR SHOOT.SCR Shoot Prone Default case for "+self.weapongroup+" weapon group - fix shoot.scr")
  180.                 break
  181.         }
  182.         break
  183.  
  184.     knees:
  185.     crawl:
  186.     floor:
  187.         // Incapacitated, so we can't shoot.
  188.         println "ERROR SHOOT.SCR Trying to shoot while in pain."
  189.         waitexec anim/idle.scr
  190.         goto start
  191.     default:
  192.         println ("ERROR SHOOT.SCR Shoot Default case for "+self.position+" position - fix shoot.scr")
  193.         waitexec anim/idle.scr
  194.         goto start
  195. }
  196. end
  197.  
  198. //=============================================================
  199. //=============================================================
  200. PlayShootActionAnim:
  201.     self.playedhipshootanim = 0
  202.  
  203.     switch (self.weapon)
  204.     {
  205.         case "springfield '03 sniper":
  206.         case "mauser kar 98k":
  207.         case "mauser kar 98d sniper":
  208.             //NOTE: self.hipshootdistance set in default_inithandler.scr
  209.             if (self.distancetoenemy < self.hipshootdistance)
  210.             {
  211.                 self setactionanim kar98_hipshot -60 60
  212.                 self.playedhipshootanim = 1
  213.             }
  214.             else
  215.             {
  216.                 if (self.roundsinclip <= 1)
  217.                 {
  218.                     self setactionanim (self.weapongroup + "_shoot") -60 60
  219.                 }
  220.                 else
  221.                 {
  222.                     self setactionanim kar98_shoot -60 60
  223.                 }
  224.             }
  225.             break
  226.         default:
  227.             self setactionanim (self.weapongroup + "_shoot") -60 60
  228.             break
  229.     }
  230. end
  231.  
  232. //=================================================
  233. //=================================================
  234. CanShoot:
  235.     if (self.enemy != NULL)
  236.     {
  237.         // check angle
  238.         local.vec = self.enemy.origin - self.origin
  239.         local.vec[2] = 0.0
  240.         local.vec = vector_normalize(local.vec)
  241.         local.angle = local.vec * self.forwardvector
  242.         if (local.angle > 0.95 && (self cansee self.enemy))        // ~10deg
  243.         {
  244.             self.canshoot = 1
  245.         }
  246.         else
  247.         {
  248.             self.canshoot = 0
  249.         }
  250.     }
  251.     else
  252.     {
  253.         self.canshoot = 0
  254.     }
  255. end
  256.